"""Created the 2013-08-25 14:33 

@author:
"""
from libatomism import *
from PySide import QtCore, QtGui
from msWidget import *


class msZMatWidget(msWidget):
    """
    graphical component for msZMat
    """
    def __init__(self, objectdb, mainwindow):
        super(msZMatWidget, self).__init__(objectdb,mainwindow)
        
        self.data = objectdb
        self. mainWindow = mainwindow
        self.initUI()
        if(not self.data.isDerivedFrom("msZMat")):
            raise Exception("uiZMat can be instanciated only "+
                                      "with a msZMat derived object.")
            
    def initUI(self):
        
        self.vbox.addWidget(QtGui.QLabel("Hello, you develop here the graphic interface for msZMat" ))
        self.zmatTextEdit = QtGui.QTextEdit(self.data.getString())
        self.vbox.addWidget( self.zmatTextEdit )
        self.updateBttn = QtGui.QPushButton("update structure")
        self.updateBttn.clicked.connect(self.updateStructure)
        self.vbox.addWidget( self.updateBttn  ) 
        
        self.setMaximumHeight(300)
  
    def updateStructure(self):

        print str(self.zmatTextEdit.toPlainText() )
        self.data.set(str(self.zmatTextEdit.toPlainText() ))
        